Skip to content

chore(db): sync schema dump with merged migrations - #997

Merged
rickyrombo merged 2 commits into
mainfrom
mjp-sync-test-schema
Jul 30, 2026
Merged

chore(db): sync schema dump with merged migrations#997
rickyrombo merged 2 commits into
mainfrom
mjp-sync-test-schema

Conversation

@rickyrombo

Copy link
Copy Markdown
Contributor

Regenerates sql/01_schema.sql and sql/03_migration_tracker.sql via make test-schema.

The committed schema dump had drifted behind several already-merged migrations (~0218–0228) that were never dumped. Since the Go test suite builds its Postgres template from sql/01_schema.sql (not by running migrations), this brings the test-template schema back in sync with the migrations on main.

No functional change — dump/tracker regeneration only.

🤖 Generated with Claude Code

Regenerate sql/01_schema.sql and sql/03_migration_tracker.sql via
`make test-schema`. The committed dump had drifted behind several
already-merged migrations (~0218-0228); this brings the test-template
schema back in sync. No functional change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regenerating the schema dump activates the delta-based social-aggregate
triggers introduced in #898 (on_save/on_follow/on_repost now fire on
INSERT OR UPDATE and adjust counts by a delta instead of recomputing).
The shared aggregate_user fixture seeded user 1's track_save_count to 20,
which the old recompute trigger overwrote but the delta trigger instead
treats as a baseline (20 + 3 seeded saves = 23), breaking
TestGetUsersAccount. Seed the pre-save baseline of 0 so the trigger
builds the intended count of 3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rickyrombo
rickyrombo merged commit 6dfda1c into main Jul 30, 2026
2 checks passed
@rickyrombo
rickyrombo deleted the mjp-sync-test-schema branch July 30, 2026 05:43
rickyrombo added a commit that referenced this pull request Aug 3, 2026
…StatsJob) (#998)

> ⚠️ **Stacked on #997** (base branch is `mjp-sync-test-schema`). Merge
#997 first; this PR's schema diff shows only the new objects because the
pending dump drift lives in #997. After #997 merges, this rebases onto
`main` cleanly.

## What

Adds `CoinStatsOnchainJob` — an on-chain replacement for the
Birdeye-backed `CoinStatsJob`, which is ~99.6% of our Birdeye
compute-unit spend. It derives the coin stats the product actually
renders from data we already index on-chain, instead of calling Birdeye:

| Field | Source |
|---|---|
| price | `artist_coin_prices` view (Meteora DBC/DAMM v2 pools) |
| holder | `sol_token_account_balances` (distinct owners, balance > 0) |
| liquidity | pool **TVL** = base-side USD + quote-side USD (real
reserves) |
| total_supply / market_cap | RPC `getTokenSupply`; `price × supply` |
| total_volume(_usd) | running accumulator over pool quote-vault balance
changes |
| history_24h_price / price_change_24h_percent | new hourly
price-history table |

## Shadow rollout

The job writes a **new `artist_coin_stats_onchain` table** and runs
**alongside** the existing `CoinStatsJob` (both every 15 min). Consumers
still read the live `artist_coin_stats`, so there's **zero product
impact**. The new `artist_coin_stats_comparison` view exposes per-coin
Birdeye-vs-on-chain deltas for validation. Once validated, a follow-up
PR repoints consumers and deletes `CoinStatsJob` + the unused Birdeye
methods.

`AudioPriceJob` (the AUDIO→USD anchor, still Birdeye) is intentionally
out of scope.

## Also

- New tables: `artist_coin_stats_onchain`, `artist_coin_price_history`,
`artist_coin_volume_accumulator` (migrations 0229–0231).
- `database/seed.go`: base rows for the new tables +
`sol_meteora_dbc_pools`.
- Test `coin_stats_onchain_test.go` seeds a DBC coin and asserts every
derived field + the AUDIO no-clobber guard.

## Known fidelity gaps vs Birdeye

We track one canonical pool per coin, so a graduated coin with
secondary/external markets will have understated liquidity/volume (price
stays close via arbitrage); there's also a brief migration-lag window.
The comparison view is the detector — review it before cutover. 24h
change is blank for the first ~24h after deploy (no snapshot yet).

## Test

`go test ./jobs/ ./database/` pass; full build/vet clean; regenerated
dump loads.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant